package com.njh.tools.base;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.njh.tools.common.string.StringUtils;


public abstract class BaseViewHolder<T> extends RecyclerView.ViewHolder {
    public Context mContext;
    public BasePresenter mPresenter;
    public boolean isSolve;

    public BasePresenter getmPresenter() {
        return mPresenter;
    }

    public void setmPresenter(BasePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    public void setSolve(boolean isSolve) {
        this.isSolve = isSolve;
    }

    public BaseViewHolder(View v) {
        super(v);
        mContext = v.getContext();
//        ViewUtil.autoFind(this, v);//id与name一致
    }

    /**
     * ViewHolder的Type，同时也是它的LayoutId
     *
     * @return
     */
    public abstract int getType();

    /**
     * 绑定ViewHolder
     *
     * @return
     */
    public abstract void onBindViewHolder(View view, T obj);

    public void setTextValue(TextView tv, String value) {
        if (!StringUtils.isEmpty(value)) {
            tv.setVisibility(View.VISIBLE);
            tv.setText(value);
        } else {
            tv.setVisibility(View.GONE);
        }
    }
}
